package com.zmn.plat.services.impl.channel.workorder.video;

import com.zmn.common.utils.date.DateUtil;
import com.zmn.plat.model.entity.channel.workorder.video.ChannelWorkOrderVideo;
import com.zmn.plat.model.entity.channel.workorder.video.ChannelWorkOrderVideoQuery;
import com.zmn.plat.persistence.interfaces.channel.workorder.video.ChannelWorkOrderVideoDao;
import com.zmn.plat.services.interfaces.channel.workorder.video.ChannelWorkOrderVideoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 类描述：
 *
 * @author yangshuangping
 * @since 2021/06/07 15:22
 */
@Service
@Slf4j
public class ChannelWorkOrderVideoServiceImpl implements ChannelWorkOrderVideoService {

    /**
     * 获取工单视频dao
     */
    @Resource
    ChannelWorkOrderVideoDao channelWorkOrderVideoDao;


    @Override
    public ChannelWorkOrderVideo findByKey(Integer id) {

        return channelWorkOrderVideoDao.findByKey(id);
    }

    @Override
    public List<ChannelWorkOrderVideo> listPageByQuery(ChannelWorkOrderVideoQuery query) {

        // 设置分页总数
        query.setTotalCount(countByQuery(query));
        // 服务分类
        return channelWorkOrderVideoDao.listPageByQuery(query);
    }

    @Override
    public List<ChannelWorkOrderVideo> listByQuery(ChannelWorkOrderVideoQuery query) {
        return channelWorkOrderVideoDao.listByQuery(query);
    }

    @Override
    public Integer countByQuery(ChannelWorkOrderVideoQuery query) {

        return channelWorkOrderVideoDao.countByQuery(query);
    }

    @Override
    public Integer findMaxSort() {

        return channelWorkOrderVideoDao.findMaxSort();
    }

    @Override
    public Integer insert(ChannelWorkOrderVideo channelVideo) {

        Integer count = channelWorkOrderVideoDao.insert(channelVideo);
        log.info("#channel-insert-video#,updater：{},time：{}", channelVideo.getUpdater(), DateUtil.getNowFormatted());
        return count;
    }

    @Override
    public Integer updateByKey(ChannelWorkOrderVideo video) {

        Integer count = channelWorkOrderVideoDao.updateByKey(video);
        log.info("#channel-update-video#,updater：{},time：{}", video.getUpdater(), DateUtil.getNowFormatted());
        return count;
    }

    @Override
    public void deleteByKey(Integer videoId) {
        channelWorkOrderVideoDao.deleteByKey(videoId);
    }

    @Override
    public void deleteByChannelId(Integer channelId) {
        channelWorkOrderVideoDao.deleteByChannelId(channelId);
    }


    @Override
    public void copy(Integer originalChannelId, Integer targetChannelId, String operator) {

        channelWorkOrderVideoDao.copy(originalChannelId, targetChannelId, operator);
    }


}
